<div ng-controller="WalletSendController" ng-if="wallet.loaded">
  <div class="row om-row">
    <div class="col-xs-12">
      <div class="text-left om-title">{{ 'WALLET.SEND.TITLE' | translate}}</div>
      <!-- <div ng-show="showErrors" class="alert alert-danger"> <strong> {{error}} </strong>  -->
    </div>
  </div> 
  <div class="row">
    <div class="col-sm-12">  
      <form name="sendForm" ng-submit="sendTransaction()">
        <div class="panel panel-form">
          <div class="panel-body">
            <div class="col-sm-6">
              <label for="chooseCoin" >{{ 'WALLET.SEND.CHOOSECOIN' | translate}}</label>
              <div class="btn-group send-asset-dropdown">
                <button class="btn btn-clear dropdown-toggle" type="button" id="chooseCoin" data-toggle="dropdown" aria-expanded="false">
                  {{selectedAsset.name | truncate:14}} <small class="text-muted" ng-show="selectedAsset.id > 0">({{selectedAsset.id}})</small>
                  <span class="caret pull-right"></span>
                </button>
                <ul class="dropdown-menu" role="menu" aria-labelledby="chooseCoin">
                  <li role="presentation" ng-repeat="asset in wallet.assets" ng-if="asset.tradable && ((asset.id < 2147483648 && asset.id != 2) || showtesteco === 'true')">
                    <a role="menuitem" tabindex="-1" href="#" ng-click="setAsset(asset)">{{asset.name | truncate:14}} <small class="text-muted" ng-show="asset.id > 0">({{asset.id}})</small></a>
                  </li>
                </ul>
              </div>
            </div> 
            <div class="col-sm-6">
              <label class="text-justify" >{{ 'WALLET.SEND.FROM' | translate}}</label>
              <div class="btn-group send-address-dropdown">
                <button class="btn btn-clear dropdown-toggle" type="button" id="chooseAddress" data-toggle="dropdown" aria-expanded="true">
                  {{selectedAddress.hash}} 
                  <span class="caret pull-right"></span>
                </button>
                <ul class="dropdown-menu" role="menu" aria-labelledby="chooseAddress">
                  <li role="presentation" ng-repeat="address in selectedAsset.tradableAddresses">
                    <a role="menuitem" tabindex="-1" href="#" ng-click="setAddress(address)">{{address.hash}} </a>
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>  
        <div class="panel panel-form">
          <div class="panel-body">
            <div class="col-sm-6">
              <label for="chooseCoin" >
                <span>{{ 'COMMON.SEND' | translate}} <span>
                <span ng-if="selectedAsset.symbol == 'BTC'">
                  {{sendByValue ? userCurrency : 'BTC'}}
                </span>
                <span ng-if="selectedAsset.symbol != 'BTC'">
                  {{ 'WALLET.SEND.AMOUNT' | translate}}
                </span>
                ({{ 'COMMON.AVAILABLE' | translate}}: {{selectedAddress.getDisplayBalance(selectedAsset.id)}} {{selectedAsset.name | truncate:14}} <small class="text-muted" ng-show="selectedAsset.id > 0">(#{{selectedAsset.id}})</small>)
              </label>
              <div class="input-group">
                <span class="input-group-addon" ng-hide="selectedAsset.symbol == 'BTC'"></span>
                <span class="input-group-addon no-padding" ng-show="selectedAsset.symbol == 'BTC' && false">
                  <div class="send-toggle">
                    <div class="btn-sendbyvalue">
                      <span></span>
                      <input type="checkbox" name="sendByValue" ng-init="sendByValue = false" ng-model="sendByValue" ng-change="convertAmount()">
                      <span></span>
                    </div>
                  </div>
                </span>
                <input id="amount" name="amount" type="number" ng-model="sendAmount" class="form-control" value="sendAmount" ng-change="amountModified=true;"
                    placeholder="{{selectedAsset.divisible ? '1.00000000' : '1'}}" step="{{selectedAsset.divisible ? 0.00000001 : 1}}" 
                    min="{{selectedAsset.divisible ? 0.00000001 : 1}}" max="{{selectedAsset.symbol != 'BTC' ? selectedAddress.getDisplayBalance(selectedAsset.id) : selectedAddress.getDisplayBalance(selectedAsset.id) - minersFee.valueOf()}}">
                <div class="hint">({{sendByValue ? ((sendAmount || 0) / selectedAsset.price).toFixed(4) : ((sendAmount || 0) * selectedAsset.price).toFixed(2)}} {{sendByValue ? 'BTC' : userCurrency}})</div>
              </div>
            </div> 
            <div class="col-sm-6">
              <label class="text-justify" >{{ 'WALLET.SEND.TO' | translate}}</label>
              <input name="reciever" type="text" ng-model="sendTo" class="form-control" ng-change="checkAddress()" required>
            </div>
          </div>
        </div>
        <p>
          {{ 'WALLET.SEND.COST' | translate}}: {{selectedAsset.symbol == 'BTC'? minersFee.valueOf() : minersFee.plus(protocolFee).valueOf()}} BTC <button type="button" class="btn btn-xs" ng-click="editTransactionCost()"><span class="glyphicon glyphicon-pencil small"></span></button>
        </p>
        <p>
          {{ 'WALLET.SEND.AVAIL' | translate}}: {{selectedAddress.getDisplayBalance(0)}} BTC 
        </p>
        <button type="button" class="btn btn-main pull-right" ng-disabled="updatingFee" ng-click="updateFee()" ng-show="selectedAsset.symbol == 'BTC' && ((amountModified || updatingFee))">{{ 'WALLET.SEND.UPDATE_FEE' | translate}}</button>
        <button type="submit" class="btn btn-main pull-right" ng-disabled="!cansend || invalidaddr || !sendForm.$valid" ng-hide="selectedAsset.symbol == 'BTC' && ((amountModified || updatingFee))">{{ 'COMMON.NEXT' | translate}}</button>
        <div ng-hide="cansend">
          <span style="color:red"> {{ 'WALLET.SEND.LOWFEE' | translate:'{topupAmount:topupAmount}' }}</span>
        </div>
        <div ng-show="invalidaddr">
          <span style="color:red"> {{ 'WALLET.SEND.INVALIDADDRESS' | translate}}</span>
        </div>
      </form>
    </div>    
  </div>
</div>
